package com.situ.blog.service.impl;



import com.situ.blog.dao.IAuthDao;
import com.situ.blog.dao.impl.AuthDaoImpl;
import com.situ.blog.pojo.Auth;
import com.situ.blog.pojo.query.AuthQuery;
import com.situ.blog.service.IAuthService;
import com.situ.blog.util.PageResult;

import java.util.List;

public class AuthServiceImpl implements IAuthService {
    private IAuthDao authDao = new AuthDaoImpl();

    @Override
    public PageResult selectByPage(AuthQuery authQuery) {
        List<Auth> list = authDao.selectByPage(authQuery);
        int totalCount = authDao.selectTotalCount(authQuery);

        PageResult<Auth> pageResult = new PageResult<>(0, "", totalCount, list);
        return pageResult;
    }

    @Override
    public void deleteById(int id) {
        authDao.deleteById(id);
    }

    @Override
    public void deleteAll(String[] ids) {
        //delete from auth where id in(2,3)
        for (String id : ids) {
            authDao.deleteById(Integer.parseInt(id));
        }
    }

    @Override
    public void add(Auth auth) {
        authDao.add(auth);
    }

    @Override
    public Auth selectById(int id) {
        return authDao.selectById(id);
    }

    @Override
    public void update(Auth auth) {
        authDao.update(auth);
    }

    @Override
    public void updateStatus(String id, int status) {
        authDao.updateStatus(id, status);
    }

    @Override
    public List<Auth> selectByRole(Integer role) {
        return authDao.selectByRole(role);
    }
}
